/**
 * 重塑矩阵
 *
 * @USER: Administrator
 * @DATE: 2024/9/23 下午11:18
 * @VERSION: 1.0.0
 */
public class LC566 {
    public int[][] matrixReshape(int[][] mat, int r, int c) {
        if (mat.length*mat[0].length != r*c) return mat;
        int[][] res = new int[r][c];
        int count = 0;
        for (int[] ints : mat) {
            for (int j = 0; j < mat[0].length; j++) {
                res[count / c][count % c] = ints[j];
                count++;
            }
        }

        return res;
    }
}
